.TH std::basic_format_arg 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::basic_format_arg \- std::basic_format_arg

.SH Synopsis
   Defined in header <format>
   template< class Context >   \fI(since C++20)\fP
   class basic_format_arg;

   Provides access to a formatting argument.

   basic_format_arg objects are typically created by std::make_format_args and accessed
   through std::visit_format_arg
   or the visit member functions
   (since C++26).

   A basic_format_arg object behaves as if it stores a std::variant of the following
   types:

     * std::monostate (only if the object was default-constructed)
     * bool
     * Context::char_type
     * int
     * unsigned int
     * long long int
     * unsigned long long int
     * float
     * double
     * long double
     * const Context::char_type*
     * std::basic_string_view<Context::char_type>
     * const void*
     * basic_format_arg::handle

.SH Member classes

   handle  type-erased wrapper that allows formatting an object of user-defined type
   (C++20) \fI(public member class)\fP

.SH Member functions

   constructor   constructs a std::basic_format_arg
   (C++20)       \fI(public member function)\fP
   operator bool checks if the current object holds a formatting argument
   (C++20)       \fI(public member function)\fP
   visit         visit the stored formatting argument
   (C++26)       \fI(public member function)\fP

.SH Non-member functions

   visit_format_arg              argument visitation interface for user-defined
   (C++20) (deprecated in C++26) formatters
                                 \fI(function template)\fP

std::basic_format_arg::basic_format_arg

   basic_format_arg() noexcept;  \fI(since C++20)\fP

   Default constructor. Constructs a basic_format_arg that does not hold a formatting
   argument. The stored object has type std::monostate.

   To create a basic_format_arg that holds a formatting argument, std::make_format_args
   has to be used.

std::basic_format_arg::operator bool

   explicit operator bool() const noexcept;  \fI(since C++20)\fP

   Checks whether *this holds a formatting argument.

   Returns true if *this holds a formatting argument (i.e. the stored object does not
   have type std::monostate), false otherwise.

std::basic_format_arg::visit

   template< class Visitor >                                         \fB(1)\fP (since C++26)
   decltype(auto) visit( this basic_format_arg arg, Visitor&& vis );
   template< class R, class Visitor >                                \fB(2)\fP (since C++26)
   R visit( this basic_format_arg arg, Visitor&& vis );

   Applies the visitor vis to the object contained in arg.

   The visit functions do not modify the basic_format_arg object on which it is called
   because a copy of the object is used when calling vis.

   1) Equivalent to return std::visit(std::forward<Visitor>(vis), v);, where v is the
   std::variant stored in arg.
   2) Equivalent to return std::visit<R>(std::forward<Visitor>(vis), v);, where v is
   the std::variant stored in arg.

.SH Notes

   Feature-test macro  Value    Std     Feature
   __cpp_lib_format   202306L (C++26) Member visit

.SH Example

    This section is incomplete
    Reason: no example

.SH See also

   basic_format_args
   format_args
   wformat_args      class that provides access to all formatting arguments
   (C++20)           \fI(class template)\fP
   (C++20)
   (C++20)

.SH Category:
     * Todo no example
